/*******************************************************************************
 * Copyright (c) 2011 Gijs de Vries aka Janoz.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Gijs de Vries aka Janoz - initial API and implementation
 ******************************************************************************/
package com.janoz.httpd;

import java.io.UnsupportedEncodingException;
import java.util.Properties;

/**
 * @author Gijs de Vries
 *
 */
public class DummyHandler implements RequestHandler {


	/**
	 * 
	 * @param uri the uri of the request
	 * @param params the get parameters of the request
	 * @return The generated response that will be sent to the client
	 */
	public Response handleRequest(String uri, Properties params) {
		StringBuffer sb = new StringBuffer();
		sb.append(uri);
		sb.append('\n');
		for (Object key : params.keySet()) {
			sb.append(key);
			sb.append(" -> ");
			sb.append(params.get(key));
			sb.append("\n");
		}
		sb.append("OK!");
		try {
			return new Response(sb.toString(), MimeType.TEXT, StatusCode.OK, null);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			return Response.createEncodingSave(StatusCode.INTERNALERROR);
		}
			
	}

}
